package ln.fxspringarchetype.vo;

import javafx.beans.property.*;
import ln.fxspringarchetype.model.Course;

public class CourseVO extends BaseFxViewModel<Course> {
    private final IntegerProperty id = new SimpleIntegerProperty();
    private final StringProperty name = new SimpleStringProperty();
    private final DoubleProperty credit = new SimpleDoubleProperty();
    private final StringProperty description = new SimpleStringProperty();

    public int getId() {
        return id.get();
    }

    public void setId(int id) {
        this.id.set(id);
    }

    public IntegerProperty idProperty() {
        return id;
    }

    public String getName() {
        return name.get();
    }

    public void setName(String name) {
        this.name.set(name);
    }

    public StringProperty nameProperty() {
        return name;
    }

    public double getCredit() {
        return credit.get();
    }

    public void setCredit(double credit) {
        this.credit.set(credit);
    }

    public DoubleProperty creditProperty() {
        return credit;
    }

    public String getDescription() {
        return description.get();
    }

    public void setDescription(String description) {
        this.description.set(description);
    }

    public StringProperty descriptionProperty() {
        return description;
    }

    @Override
    public Course toModel() {
        Course course = new Course();
        course.setId(getId());
        course.setName(getName());
        course.setDescription(getDescription());
        course.setCredit(getCredit());
        return course;
    }

    @Override
    public void fromModel(Course course) {
        setId(course.getId());
        setName(course.getName());
        setCredit(course.getCredit());
        setDescription(course.getDescription());
    }
}
